<template>
    <div>
        <p>名称：<input type="text" v-model="form.name"></p>
        <p>分类：<select name="" id="" v-model="form.cid">
            <option :value="i.id" v-for="i in cate">{{i.name}}</option>
            </select></p>
            <button @click="add">添加</button>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                form:{},
                cate:[]
            }
        },
        methods: {
            getcate(){
                this.$axios.get('/cate/cate')
                .then((res) => {
                    if(res.data.code==200){
                        this.cate = res.data.list
                    }
                    
                }).catch((err) => {
                    
                });
            },
            add(){
                this.$axios.post('/goods/goods',this.form)
                .then(res=>{
                    if(res.data.code==200){
                        alert('添加成功')
                        this.form = {}
                    }
                })
            }
        },
        mounted() {
            this.getcate()
        },
    }
</script>

<style scoped>

</style>